#include <iostream>
using namespace std;


bool check(long long x)
{
    if(x < 2)
    {
        return false;
    }
    for(int i = 2;i <= x / i;i++)
    {
        if(x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    while(n--)
    {
        long long x,y;
        cin >> x >> y;
        if(x == 1 || y == 1)
        {
            if(check(x) || check(y))
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}
// 64 位输出请用 printf("%lld")